<?php

class Form_ClientProfileForm extends Zend_Form
{
	public function init()
	{
		//$client = Model_Soap::client('default');
		//$countryList = $client->countryList();

		$locale = Zend_Registry::get('Zend_Locale');
		$locale_countries = ($locale->getTranslationList('Territory', 'en_US', 2));
		asort($locale_countries, SORT_LOCALE_STRING);
    	$countryList=array();
		$countrylist['']="--Select--";
		foreach($locale_countries as $k=>$v)
		{
			//$countrylist[$v['code']]=$v['value'];
			$countrylist[$k]=$v;
		}
		
		$table = new Model_DbTable_TimeZone();  //try to use the Zend Db Table		
		$select = $table->select()->order('timezone_id ASC');		
		$data=$table->fetchAll($select);  //$data is an object
		$timezoneList_array = $data->toArray();
		
		$timezoneList=array();
		foreach($timezoneList_array as $k=>$v)
		{
			$timezoneList[$v['timezone_id']]=$v['timezone_name'];
		}		
		//Zend_Debug::dump($timezoneList);exit;
		//set the method for the display form to POST		
		$this->setName('Profile')
			->setMethod('POST');
							
		$this->setDecorators(array(
		    'FormElements',
		    array('HtmlTag', array('tag' => 'ul')),
		    'Form',
		));
/*			
		$this->setElementDecorators(array(
		    'ViewHelper',
		    'Errors',
		    array(array('data' => 'HtmlTag'), array('tag' => 'li', 'class' => 'element')),
		    array('Label', array('tag' => 'li'),
		    array(array('row' => 'HtmlTag'), array('tag' => 'div'))
		)));
*/		
		$first_name=new Zend_Form_Element_Text('first_name');
		$first_name->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('First Name')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($first_name);

		$last_name=new Zend_Form_Element_Text('last_name');
		$last_name->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
			//->setLabel('Last Name')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($last_name);

		$website=new Zend_Form_Element_Text('website');
		$website->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('Website')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($website);

		
		$phone=new Zend_Form_Element_Text('phone');
		$phone->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
			//->setLabel('Phone')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($phone);
				
		$company=new Zend_Form_Element_Text('company');
		$company->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('Alpha')
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('Company')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
			$this->addElement($company);
		
		$address=new Zend_Form_Element_Text('address');
		$address->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
			//->setLabel('Address')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($address);
		

		$city=new Zend_Form_Element_Text('city');
		$city->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('City')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($city);
		
		$state=new Zend_Form_Element_Text('state');
		$state->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
			//->setLabel('State')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($state);
		
		$zip_code=new Zend_Form_Element_Text('zipcode');
		$zip_code->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('Zipcode')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($zip_code);
		
		$country=new Zend_Form_Element_Select('country');
		$country->addMultiOptions($countrylist)
				->setAttrib('class','field text full')				
				->setAttrib('css','width:100px');				
				//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
				//->setLabel('Country')
				//->getDecorator('Label')->setOptions(array('class'=>'desc'));
		$this->addElement($country);
		
		$timezone = new Zend_Form_Element_Select('timezone_id');
		$timezone->addMultiOptions($timezoneList)
				 ->setAttrib('class','field text full')
				->setAttrib('css','width:100px');				
		$this->addElement($timezone);

		 		 
		$submit=new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Submit')->setAttrib('css','text-align:center');
		//$submit->setAttrib('onsumit','formValidate();');
		$this->addElement($submit);
/*		
		$elements = $this->getElements(); 
		foreach($elements as $elem){
			$elem->removeDecorator('dd');
			//$elem->removeDecorator('wrapper');
		}		
*/		
/*		
		$reset=new Zend_Form_Element_Button('reset');
		$reset->setAttrib('onclick','$("#SignupSetting").reset();return false;');
		$this->addElement($reset);
*/				
	}

	public function isValid($data)
	{
		$valid = parent::isValid($data);
		return $valid;
	}

}

